Skip to content

Bug fixes for RTL text and dx/dy - #1145

Merged
LaurenzV merged 2 commits into
linebender:mainfrom
teolines:fix-rtl-relative-shift
Oct 9, 2026
Merged

LaurenzV merged 2 commits into
linebender:mainfrom
teolines:fix-rtl-relative-shift

Conversation

@teolines

Copy link
Copy Markdown
Contributor

Right-to-left text with dy shifts collapsed onto one line. The shifts are now applied in logical order instead of screen order.

Fixes #1093

LLM Contributions: investigation, implementation and tests with Claude Code, reviewed by me. The description is my own, edited for grammar.

teolines and others added 2 commits October 9, 2026 13:28
`dx` and `dy` shift a character and every character after it in logical
order, but the shifts were accumulated while positioning the clusters in
visual order. In right-to-left text, the first character is the last
cluster, so a `dy` on a `tspan` only moved its first character, and a
multi-line text collapsed onto its first line.

Accumulate the shifts in logical order before positioning the clusters.
Left-to-right text is unchanged.

Fixes linebender#1093
`text-anchor` positioned a chunk by the sum of its advances, ignoring how
`dx` and `textLength` move the characters. Anchor it by the actual extent
of its characters instead, as described by the SVG 2 text layout algorithm.
`textLength` spacing only moves characters, so it isn't part of the extent.

Text on a path also accumulated `dx` and `dy` in visual order. Share the
logical order shift resolution with horizontal text.

Text decorations were split at the cluster that owns a `dx` or `dy`, which
is only where the shift changes in left-to-right text. Split them wherever
neighboring clusters have a different shift instead.
@LaurenzV
LaurenzV force-pushed the fix-rtl-relative-shift branch from cfb199a to b1ce728 Compare October 9, 2026 14:28
@LaurenzV LaurenzV changed the title Apply dx and dy in logical order in right-to-left text Bug fixes for RTL text and tx/ty Oct 9, 2026
@LaurenzV LaurenzV changed the title Bug fixes for RTL text and tx/ty Bug fixes for RTL text and dx/dy Oct 9, 2026
@LaurenzV

LaurenzV commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Oh man text is complicated... I looked into it a bit more and found some more issues, it's probably still not 100% correctly but we have more passing tests now, so hopefully this is an improvement.

@LaurenzV

LaurenzV commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Thanks!

@LaurenzV
LaurenzV merged commit 101e3f1 into linebender:main Oct 9, 2026
5 checks passed
HiroyukiFuruno added a commit to HiroyukiFuruno/katana-resvg that referenced this pull request Oct 25, 2026
* Update Windows release runner to `windows-latest` (linebender#1113)

* c-api: add missing SVGZ error enum (linebender#1122)

Add the missing `RESVG_ERROR_SVGZ_UNSUPPORTED` enum value to `resvg.h`
so the C API enum values remain in sync with the Rust definition and
subsequent error codes are not shifted.

While we're here, simplify this enum description (as the `svgz` feature
is enabled by default) and add the corresponding Qt error string in
`ResvgQt.h`.

Fixes: linebender#1112.

---

Verified against wasm-vips with this sed substitution:

https://github.com/kleisauke/wasm-vips/blob/8f38cbbb70d7536bd0f3d70e308c501cbe4f2e22/build.sh#L442-L443

* Add regression test for `fr` resolution in referenced radial gradients (linebender#1123)

As requested in linebender#1098

* fix(usvg): use the viewport as the bbox of a sliced <image> (linebender#1077)

* Add aarch64 release artifacts for Linux and Windows (linebender#1132)

Adds native aarch64 builds to the release workflow.

- **Linux aarch64** on the `ubuntu-24.04-arm` runner →
`resvg-linux-aarch64.tar.gz`, `usvg-linux-aarch64.tar.gz`
- **Windows aarch64** on the `windows-11-arm` runner →
`resvg-win-aarch64.zip`, `usvg-win-aarch64.zip`

Updates the workflow's actions, two of which still declared the
end-of-life node12 runtime:

- `alexellis/upload-assets` 0.2.2 → 0.5.0 (node12 → node24)
- `battila7/get-version-action` removed — unmaintained since 2021 and
node12; the workflow only triggers on `v*` tags, so the version is just
`${GITHUB_REF_NAME#v}`
- `actions/checkout` v2 → v7, `softprops/action-gh-release` v2 → v3

Renames the existing job to explicitly say `x86_64` and differentiate
`aarch64`

Closes linebender#968

* Convert CI release job to use a Matrix (linebender#1133)

Some CI cleanup suggested by LLM review of
linebender#1132. Has been verified as
working on my fork.

## Changes made

- Collapse the six per-platform release-* jobs into one release-binaries
matrix job over {linux, win, macos} × {x86_64, aarch64}. Asset names are
derived from the matrix (`resvg-$SUFFIX.{tar.gz,zip}`). This renamea
`resvg-win64.zip` / `usvg-win64.zip` to `resvg-win-x86_64.zip` /
`usvg-win-x86_64.zip` to match the linux-* / macos-* / win-aarch64
naming. This is a breaking change for anyone scripting downloads of the
old names.
- Drop the crates/c-api release builds (and the ilammy/msvc-dev-cmd
step): their output was never collected or uploaded, so they only cost
CI time.
- Split the vendored sources archive and the Windows Explorer
thumbnailer into their own jobs
- Upload assets with `softprops/action-gh-release@v3` files: (already
used to create the release) instead of the third-party
`alexellis/upload-assets`.

* tests: load test fonts in a deterministic order (linebender#1136)

`fontdb::load_fonts_dir` walks the directory with `std::fs::read_dir`,
which outputs entries in filesystem order. That order is not stable
across machines, and the test harness depends on it.

Replace `load_fonts_dir` with an explicit sorted list so order is
identical everywhere. The whole suite passes unchanged, so no stored
reference image depended on the previous ordering.

* fix(usvg): inherit `gradientTransform` and `patternTransform` via `href` (linebender#1135)

* Inherit `dominant-baseline` into nested `<tspan>` elements (linebender#1086)

* Fix bug in filter chains with different filter regions (linebender#1144)

* Add support for `plus-lighter` and `lighter` (linebender#1142)

* Apply root SVG transform after the `viewBox` mapping (linebender#1085)

* Add `--query-bbox` to CLI (linebender#1050)

* Support floating point viewbox in resvg binary (linebender#875)

* Fix `feMorphology` kernel size and radius rounding (linebender#1120)

* Bug fixes for RTL text and `dx`/`dy` (linebender#1145)

* Fix font fallback logging and avoid repeated lookups (linebender#1154)

* Fix rendering of filters with skews and rotations (linebender#1155)

* Fix marker viewport clipping with preserveAspectRatio (linebender#1163)

* Resolve paint servers in masks, patterns and `feImage` before caching (linebender#1164)

* Optimize clipped layers (linebender#1158)

* Remove reference to nonexistent check.py from tests README (linebender#1181)

* Install ResvgQt.h with cargo-c (linebender#1182)

* Prepare v0.49.0 release (linebender#1183)

* fix: Windowsサムネイルの依存版を0.49へ揃える Refs #1

---------

Co-authored-by: TheBestWebsite <164817940+TheBestWebsite@users.noreply.github.com>
Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl>
Co-authored-by: Tim Voßhenrich <94936637+T1mVo@users.noreply.github.com>
Co-authored-by: Stefano <stefano.d@posteo.de>
Co-authored-by: Chongyi Zheng <git@zcy.dev>
Co-authored-by: Nico Burns <nico@nicoburns.com>
Co-authored-by: Luis de Bethencourt <luis@debethencourt.com>
Co-authored-by: Quaylyn Rimer <31830590+killerdevildog@users.noreply.github.com>
Co-authored-by: Teo Mal <76534902+teolines@users.noreply.github.com>
Co-authored-by: Matt Hargett <plaztiksyke@gmail.com>
Co-authored-by: Simon Ser <contact@emersion.fr>
Co-authored-by: Jeremy James <jeremy.james@gmail.com>
Co-authored-by: WaterWhisperer <waterwhisperer24@qq.com>
Co-authored-by: Laurenz Stampfl <47084093+LaurenzV@users.noreply.github.com>
Co-authored-by: Cees-Kettenis <101450983+Cees-Kettenis@users.noreply.github.com>
Co-authored-by: Rodrigue Villetard <rodrigue@gassagosso.coop>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RTL text with multi-line <tspan dy> layout collapses onto one line (usvg 0.47.0)

2 participants